package cn.appsys.service.impl;

import cn.appsys.dao.AppInfoDao;
import cn.appsys.dao.AppVersionDao;
import cn.appsys.pojo.AppVersion;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

import cn.appsys.service.AppVersionService;

@Service
public class AppVersionServiceImpl implements AppVersionService {

	@Autowired
	AppVersionDao appVersionDao;
	
	@Autowired
	AppInfoDao appInfoDao;

	@Override
	public List<AppVersion> selectAppVersionList(Long appId) {
		return appVersionDao.selectAppVersionList(appId);
	}

	@Override
	public boolean addAppVersion(AppVersion appVersion) {
		//1.添加版本
		int n = appVersionDao.addAppVersion(appVersion);
		//2.更新最新版本号
		return n > 0 && 
				appInfoDao.updateVersionId(appVersion.getAppId(), appVersion.getId()) > 0;
	}

	@Override
	public AppVersion getAppVersionById(Long id) {
		return appVersionDao.getAppVersionById(id);
	}

}
